<%@page contentType="text/html" pageEncoding="MacRoman"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>RSS Agregator</title>
        <link type="text/css" href="<s:url value="/stylesheets/common.css" />" rel="stylesheet" media="screen" />
        <link type="text/css" href="<s:url value="/stylesheets/basic.css" />" rel="stylesheet" media="screen" />
    </head>
    <body>      
        <jsp:include page="header.jsp"/>
        <!-- Start Main Content -->
        <div id="main" class="container">
        	<div class="searchbox">
	        	<s:textfield id="searchbox" size="70"></s:textfield>
	        	<button onclick="search()">Go!</button>
	        </div>
	        <div id="leftcolumn">
            	<jsp:include page="categories.jsp"/>
            	<div id="categSuggestion">
            		<jsp:include page="categorie-suggestion.jsp"/>
            	</div>
            </div>
            <!-- main content area -->
            <div id="center">
                <jsp:include page="filterfeeds.jsp"/>
            </div>
            <div id="feedsSuggestions" class="product_wrapper">
            	<jsp:include page="feeds-suggestions.jsp" />
            </div>
        </div>
        
        <script type="text/javascript" src="<s:url value="/js/libs/jquery-1.7.1.min.js" />"></script>
        <script type="text/javascript">
        
        	function search() {
        		addResultFeeds( $("#searchbox").val(), true );	
        	}
        	
        	function addResultFeeds(keywords,search) {
        		
        		$.ajax({
	                url: "filter-feeds.action?keywords="+keywords+"&search="+(search==true?1:0),
	                dataType: "html",
	                success: function(content) {
	                   $("#center").html(content);
	                }
	            });
        		
        		if( !search ) {
        			$.ajax({
    	                url: "categorie-suggestion.action?keyword="+keywords,
    	                dataType: "html",
    	                success: function(content) {
    	                   $("#categSuggestion").html(content);
    	                }
    	            });
            		
            		$.ajax({
    	                url: "feeds-suggestions.action?keyword="+keywords,
    	                dataType: "html",
    	                success: function(content) {
    	                   $("#feedsSuggestions").html(content);
    	                }
    	            });
        		}
        	}
        	
			function getFeedsByCategory(obj) {
				addResultFeeds( $(obj).text(), false );
				return false;
			}
			
		</script>           
    </body>
</html>
